﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "IActionOffsetBehavior.h"

namespace gcmp
{
    // 派生定制接口
    class GbmpOffsetActionBehavior final : public IActionOffsetBehavior
    {
    public:
        GbmpOffsetActionBehavior();
        virtual ~GbmpOffsetActionBehavior();

    public:
        virtual bool DefineInputDialog(std::wstring &title, std::vector<OwnerPtr<gcmp::IControlDefinition>>& inputItems) override;
        virtual bool OnActionInputEvent(IActionInputEventArgs* pArgs) override;

    public:
        virtual bool OnOffsetFinished(gcmp::IDocument* pDoc,
            const IPlane* pWorkPlane,
            const gcmp::GraphicsNodeReferenceOwnerPtrVector& gNodeReferencesSelection,
            const std::vector<std::pair<ElementId, std::vector<OwnerPtr<ICurve3d>>>>& offsetElementCurves) override;

        virtual bool OnOffsetFinished(gcmp::IDocument* pDocument,
            const Coordinate3d& coordinate,
            const gcmp::GraphicsNodeReferenceOwnerPtrVector& gNodeReferencesSelection,
            const std::vector<OwnerPtr<IPolyCurve>>& offsetPolyCurves) override;

    public:
        virtual bool OnUpdatePreview(gcmp::IUiView* pCurrentView,
            const gcmp::Vector3d& mousePoint,
            const std::vector<OwnerPtr<gcmp::ICurve3d>>& opCurves, 
            OwnerPtr<IGraphicsNodeGroup>& opGNodeGroup) override;

        virtual bool OnUpdatePreview(gcmp::IUiView* pCurrentView,
            const Coordinate3d& coordinate,
            const gcmp::Vector3d& mousePoint,
            const std::vector<OwnerPtr<IPolyCurve>>& offsetPolyCurves,
            OwnerPtr<IGraphicsNodeGroup>& opGNodeGroup) override;

    public:
        virtual bool GetIsFixedOffsetValue(bool& isFixed) const override;
        virtual bool GetFixedOffsetValue(double& offset) const override;
        virtual bool GetIsCopyElementOnOffsetFinished(bool& isCopy) const override;
        virtual bool GetIsPolyLineElementOnOffsetFinished(bool& isPolyLine) const override;
        virtual bool GetIsActionStateChanged() const override;
        virtual OwnerPtr<IPickFilter> GetOffsetPickFilter(IDocument* pDocument) const override;

    private:
        static double S_offsetValue;
        bool m_isFixedOffsetValue;
        bool m_isCopyElement;
        double m_dOffsetValue;

        bool m_bActionStateChaged;
    };
}
